package se.sll.service.catalogue.common.property;

import java.io.Serializable;
import java.util.Properties;

/**
 *
 * @author Jiri Uosukainen
 */
public class CatalogProperties implements IM1Properties, Serializable{

    //Final properties
    public static final String JMS_CONNECTION_FACTORY = "java:/jms/ConnectionFactory";
    public static final String JMS_POOLED_CONNECTION_FACTORY = "java:/jms/PooledConnectionFactory";
    public static final String JMS_EI_QUEUE_JNDI = "jms/eiQueue";
    public static final String JMS_DLQ_JNDI = "jms/queue/DLQ";
    public static final String JMS_SMTP_QUEUE_JNDI = "jms/queue/smtpQueue";

    private static final String VALUE_NOT_SET = "VALUE_NOT_SET";
    private static final long serialVersionUID = 1L;

    private Properties props = new Properties();
    
    public enum NAME implements M1Properties.NAMED_PROPERTY{

        CAPACITY_OID("se.sll.servicecatalog.capacity.type.oid", "The OID for internal capacity types")

        , OFFERS_BASE_URL("se.sll.servicecatalog.offer.url", "The url to offer service")
        , CAPACITY_BASE_URL("se.sll.servicecatalog.capacity.url", "The url to capacity service")
        , PRODUCT_BASE_URL("se.sll.servicecatalog.product.url", "The url to product service")
        , USER_BASE_URL("se.sll.servicecatalog.user.url", "The url to user service")
        , IDMAP_BASE_URL("se.sll.servicecatalog.idmap.url", "The url to idmap service")
        , EI_VIRTUAL_SERVICE_URL("se.sll.servicecatalog.ei.url", "The url to the EI virtual service")

        , SMTP_MAILSERVER_HOST("se.sll.servicecatalog.smtpserver.host", "The hostname for the smtp server")
        , SMTP_MAILSERVER_PORT("se.sll.servicecatalog.smtpserver.port", "The port for the smtp server")
        
        , NOTIFICATION_OFFERS_ACTIVE("se.sll.servicecatalog.notif.offers.active", "Activates notification for updated offers (true|false)")

        , NOTIFICATION_CAPACITY_MAX_REDELIVERIES("se.sll.servicecatalog.notif.capacity.maxredeliveries", "Max number of redeliveries for mail (integer)")
        , NOTIFICATION_CAPACITY_ACTIVE("se.sll.servicecatalog.notif.capacity.active", "Activates notification for expiring capacity (true|false)")
        , NOTIFICATION_CAPACITY_EXPIRATION_PERIOD_DAYS("se.sll.servicecatalog.notif.capacity.expiration.period", "Controls how long before(days) expiration of capacity we start to notify")
        , NOTIFICATION_CAPACITY_SMTP_FROM("se.sll.servicecatalog.notif.capacity.smtp.header.from", "Value for 'from' header for capacity notification (smtp)")
        , NOTIFICATION_CAPACITY_SMTP_SUBJECT("se.sll.servicecatalog.notif.capacity.smtp.header.subject", "Value for 'subject' header for capacity notification (smtp)")
        , NOTIFICATION_CAPACITY_SMTP_MESSAGE("se.sll.servicecatalog.notif.capacity.smtp.message", "The message body contents in notification smtp")
        , NOTIFICATION_CAPACITY_SMTP_LINK_URL_TO_GUI("se.sll.servicecatalog.notif.capacity.smtp.message.linkurl", "The url to admin interface, used in email notification message")
        , NOTIFICATION_CAPACITY_SMTP_LINK_NAME_TO_GUI("se.sll.servicecatalog.notif.capacity.smtp.message.linkname", "The name of the link to admin interface, used in email notification message")

        , NOTIFICATION_EI_LOGICAL_ADDRESS("se.sll.servicecatalog.notif.ei.message.logicaladdress", "The logical address value used in calls to EI")
        , NOTIFICATION_EI_CATEGORIZATION("se.sll.servicecatalog.notif.ei.message.category", "The category value used in EI payload")
        , NOTIFICATION_EI_SERVICEDOMAIN("se.sll.servicecatalog.notif.ei.message.servicedomain", "The servicedomain value used in EI payload")
        , NOTIFICATION_EI_SOURCESYSTEM("se.sll.servicecatalog.notif.ei.message.sourcesystem", "The sourcesystem value used in EI payload")

        , SNOD_VTGET_HOST("se.sll.servicecatalog.snod.vtget.host", "Hostname for vtget")
        , SNOD_VTGET_PORT("se.sll.servicecatalog.snod.vtget.port", "Port for vtget")
        , SNOD_VTGET_SERVICE("se.sll.servicecatalog.snod.vtget.service", "Servicename for vtget")
        , SNOD_VTGET_USERNAME("se.sll.servicecatalog.snod.vtget.username", "Username for vtget")
        , SNOD_VTGET_PASSWORD("se.sll.servicecatalog.snod.vtget.password", "Password for vtget")

        , SYSTEM_USER_USERNAME("se.sll.servicecatalog.system.user.username", "Username for system user")
        , SYSTEM_USER_PASSWORD("se.sll.servicecatalog.system.user.password", "Password for system user")
        , PRODUCT_OID("se.sll.servicecatalog.product.type.oid", "The OID for SLL product codesystem")
        ;
        
        private final String propertyName;
        private final String description;
        
        private NAME(String propertyName, String description){
            this.propertyName = propertyName;
            this.description = description;
        }
        
        @Override
        public String propertyName(){
            return this.propertyName;
        }
        
        @Override
        public String description(){
            return this.description;
        }
    }
    
    public static String getProperty(NAME property){
        return M1Properties.getInstance().getNamedProperty(property);
    }
    
    @Override
    public Properties getProperties() 
    {
        props.setProperty(NAME.CAPACITY_OID.propertyName(), "oid.sll.vantetider");

        // URL:s
        props.setProperty(NAME.OFFERS_BASE_URL.propertyName(), "http://localhost:8080/offers");
        props.setProperty(NAME.USER_BASE_URL.propertyName(), "http://localhost:8080/gui");
        props.setProperty(NAME.PRODUCT_BASE_URL.propertyName(), "http://localhost:8080/product");
        props.setProperty(NAME.CAPACITY_BASE_URL.propertyName(), "http://localhost:8080/capacity");
        props.setProperty(NAME.IDMAP_BASE_URL.propertyName(), "http://localhost:8080/idmap");
        props.setProperty(NAME.EI_VIRTUAL_SERVICE_URL.propertyName(), "http://localhost:8088/mockUpdateResponderBinding");
        
        // SMTP server
        props.setProperty(NAME.SMTP_MAILSERVER_HOST.propertyName(), "mailrelay.centrera.se");
        props.setProperty(NAME.SMTP_MAILSERVER_PORT.propertyName(), "25");
        
        // Notification capacity mail
        props.setProperty(NAME.NOTIFICATION_CAPACITY_MAX_REDELIVERIES.propertyName(), "10");
        props.setProperty(NAME.NOTIFICATION_CAPACITY_ACTIVE.propertyName(), "true");
        props.setProperty(NAME.NOTIFICATION_CAPACITY_EXPIRATION_PERIOD_DAYS.propertyName(), "14");
        props.setProperty(NAME.NOTIFICATION_CAPACITY_SMTP_FROM.propertyName(), "servicedesk@sll.se");
        props.setProperty(NAME.NOTIFICATION_CAPACITY_SMTP_SUBJECT.propertyName(), "Uppdatering av väntetider");
        props.setProperty(NAME.NOTIFICATION_CAPACITY_SMTP_MESSAGE.propertyName(), "Vänligen uppdatera dina väntetider genom att följa länken nedan!");
        props.setProperty(NAME.NOTIFICATION_CAPACITY_SMTP_LINK_URL_TO_GUI.propertyName(), "http://localhost:8080/gui");
        props.setProperty(NAME.NOTIFICATION_CAPACITY_SMTP_LINK_NAME_TO_GUI.propertyName(), "Väntetider");
        
        // Notification offers
        props.setProperty(NAME.NOTIFICATION_OFFERS_ACTIVE.propertyName(), "true");
        props.setProperty(NAME.NOTIFICATION_EI_LOGICAL_ADDRESS.propertyName(), VALUE_NOT_SET);
        props.setProperty(NAME.NOTIFICATION_EI_CATEGORIZATION.propertyName(), "OFFER");        
        props.setProperty(NAME.NOTIFICATION_EI_SERVICEDOMAIN.propertyName(), VALUE_NOT_SET);        
        props.setProperty(NAME.NOTIFICATION_EI_SOURCESYSTEM.propertyName(), VALUE_NOT_SET);        

        // SNOD-VTGET
        props.setProperty(NAME.SNOD_VTGET_HOST.propertyName(), VALUE_NOT_SET);
        props.setProperty(NAME.SNOD_VTGET_PORT.propertyName(), VALUE_NOT_SET);
        props.setProperty(NAME.SNOD_VTGET_SERVICE.propertyName(), VALUE_NOT_SET);
        props.setProperty(NAME.SNOD_VTGET_USERNAME.propertyName(), VALUE_NOT_SET);
        props.setProperty(NAME.SNOD_VTGET_PASSWORD.propertyName(), VALUE_NOT_SET);
        
        // SYSTEM USER
        props.setProperty(NAME.SYSTEM_USER_USERNAME.propertyName(), VALUE_NOT_SET);
        props.setProperty(NAME.SYSTEM_USER_PASSWORD.propertyName(), VALUE_NOT_SET);
        
        // OID
        props.setProperty(NAME.PRODUCT_OID.propertyName(), "oid.sll.product.catalogue");

        return props;
    }
}